﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using HST.Domain.Seedwork;
using HST.Infrastructure.Data.Seedwork;

namespace HST.ZWParking.Infrastructure.Data.EntityFramework
{
    public class UnitOfWork : IUnitOfWork
    {
        private readonly IDatabaseFactory databaseFactory;
        private ZWParkingContext dataContext;

        public UnitOfWork(IDatabaseFactory databaseFactory)
        {
            this.databaseFactory = databaseFactory;
        }

        protected ZWParkingContext DataContext
        {
            get { return dataContext ?? (dataContext = (ZWParkingContext)databaseFactory.Create()); }
        }

        public void Commit()
        {
            DataContext.Commit();
        }

        public void Rollback()
        {
            dataContext.Rollback();
        }

        public void Dispose()
        {
        
        }
    }
}
